<?php
function oc_get_plugins() {
	$plugin_root = ABSPATH . PLUGINDIR.'/oneclick/temp';
	// Files in wp-content/plugins directory
	$plugins_dir = @ dir( $plugin_root);
	if ( $plugins_dir ) {
		while (($file = $plugins_dir->read() ) !== false ) {
			if ( substr($file, 0, 1) == '.' )
				continue;
			if ( is_dir( $plugin_root.'/'.$file ) ) {
				$plugins_subdir = @ dir( $plugin_root.'/'.$file );
				if ( $plugins_subdir ) {
					while (($subfile = $plugins_subdir->read() ) !== false ) {
						if ( substr($subfile, 0, 1) == '.' )
							continue;
						if ( substr($subfile, -4) == '.php' || substr($subfile, -4) == '.css' )
						{
							$plugin_files[] = "$file/$subfile";
							if(substr($subfile, -4) == '.css')
								$basefile=$file;
						}
					}
				}
			} else {
				if ( substr($file, -4) == '.php' )
					$plugin_files[] = $file;
			}
		}
	}

	foreach ( $plugin_files as $plugin_file ) {
		if ( !is_readable( "$plugin_root/$plugin_file" ) )
			continue;
		$plugin_data = get_plugin_data( "$plugin_root/$plugin_file" );
		if ( empty ( $plugin_data['Name'] ) )
			continue;
		$plugin_data['Type']='plugin';
		$plugin_data['Path']=$plugin_file;
		return $plugin_data;		
	}
	foreach ( $plugin_files as $plugin_file ) {
		if ( !is_readable( "$plugin_root/$plugin_file" ) )
			continue;
		$plugin_data = get_theme_data( "$plugin_root/$plugin_file" );
		if ( empty ( $plugin_data['Name'] ) )
			continue;
		$plugin_data['Type']='theme';
		$plugin_data['Path']=$basefile;
		return $plugin_data;
	}
	$plugin_data['Name']='oc_error_notfound';
	return $plugin_data;
}?>

<?php function show_zeitgeist()
{ ?>
<div id="zeitgeist">
<h2>OneClick Status</h2>
<h3>Write Methods</h3>
<ul>
<li>Safe Write: Enabled</li>
<li>Safe Unzip: Enabled</li>
<li>Safe Delete: Enabled</li>
</ul>
<h3>Other Details</h3>
<ul>
<li>Remote ZIP Fetching: Supported</li>
<li>Update: No Update</li>
</ul>
<h3>Stats</h3>
<ul>
<li>OneClick has installed 32 plugins and 12 themes</li>
<li>Update: No Update</li>
</ul>
</div>
<?php } ?>